#ifndef QRAWSOCKET_H
#define QRAWSOCKET_H

#include <QAbstractSocket>

#if defined(Q_OS_WIN)
#include <winsock2.h>
#include <ws2tcpip.h>
#include "wstcpip.h"
#else
#include <linux/icmp.h>
#endif

class QRawSocket: public QAbstractSocket
{
    Q_OBJECT

public:
    explicit QRawSocket(QObject *parent = nullptr);
    explicit QRawSocket(int protocol, QObject *parent = nullptr);
    bool open(int protocol);
    quint32 sendTo(const char *data, quint32 size, const QString &address);
    quint32 sendIcmpEcho(const QString &address, quint16 id, quint16 sequence, quint16 len);
    static quint16 checkSum(const quint16 *data, int size);

private:
    int protocol;
};

#endif // QRAWSOCKET_H
